<template>
	<view>
		<uni-forms ref="queryForm" v-model="queryParams">
			<uni-forms-item label="案件编号" label-width="85" v-if="isShow">
				<uni-easyinput v-model="queryParams.caseCode" placeholder="案件编号"></uni-easyinput>
			</uni-forms-item>
			<uni-forms-item label="案件来源" label-width="85">
				<uni-data-select v-model="queryParams.rptChannelId" :localdata="sourceOptions"></uni-data-select>
			</uni-forms-item>
			<uni-forms-item label="案件级别" label-width="85">
				<uni-data-select v-model="queryParams.caseGrade" :localdata="levelOptions"></uni-data-select>
			</uni-forms-item>
			<uni-forms-item label="上报时间" label-width="85">
				<uni-datetime-picker v-model="queryParams.reportTime" type="daterange"/>
			</uni-forms-item>
		</uni-forms>
		<view style="display: flex;">
			<button size="mini" class="common-btn other-btn" @click="handleRepeat">重置</button>
			<button size="mini" class="common-btn primary-btn" @click="handleQuery">查询</button>
		</view>
	</view>
</template>

<script>
	import { getDicts } from "@/api/system/dict/data";
	export default {
		name:"case-query",
		props:{
			isShow:{
				type:Boolean,
				default:true
			}
		},
		data() {
			return {
				queryParams:{},
				sourceOptions:[],
				levelOptions:[]
			};
		},
		created() {
			//问题来源
			getDicts("case_source").then(response => {
				console.log(JSON.stringify(response));
				this.sourceOptions = response.data.map(item => {
					return {
						value:item.dictValue,
						text:item.dictLabel
					}
				})
			});
			getDicts("case_level").then(response => {
				this.levelOptions = response.data.map(item => {
					return {
						value:item.dictValue,
						text:item.dictLabel
					}
				})
			});
		},
		methods:{
			handleRepeat(){
				this.queryParams.caseCode=null;
				this.queryParams.rptChannelId=null;
				this.queryParams.caseGrade=null;
				this.queryParams.reportTime=null;
				// this.queryParams = {}
				// this.$refs.queryForm.resetFields()
				console.log(JSON.stringify(this.queryParams))
			},
			handleQuery(){
				if(this.queryParams.reportTime &&　this.queryParams.reportTime.length>0){
					let params = {
						"rptTimeStart":this.queryParams.reportTime[0]+" 00:00:00",
						"rptTimeEnd":this.queryParams.reportTime[1]+" 23:59:59"
					}
					this.queryParams.params = params;
				}
				this.$emit("query",this.queryParams);
			}
		}
	}
</script>

<style>

</style>